package tests;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

import pnt.message.Request_Resolve;
import pnt.message.parser.PNTParser;
import junit.framework.TestCase;

public class testParsingOfResolveMessage extends TestCase {

	Request_Resolve r1;
	String s1;
	
	Request_Resolve r2;
	String s2;
	
	protected void setUp() throws Exception {
		super.setUp();
		
		s1 = 
			"RESOLVE * PNT/1.0 \r\n" +
			"Transaction: 2342 \r\n" +
			"Application: Skype" +
			"\r\n\r\n\r\n";

		s2 =
			"RESOLVE SN:bob PNT/1.0 \r\n" +
			"Transaction: 2342 \r\n" +
			"Application: Skype" +
			"\r\n\r\n\r\n";
		
		String concat = s1 + s2;
			
			InputStream i1 = new ByteArrayInputStream(concat.getBytes() );
			
			PNTParser p = new PNTParser(i1);

			r1 = (Request_Resolve)p.getNextMessage();
			assertTrue("Parsing Failed", r1 != null);
			
			r2 = (Request_Resolve)p.getNextMessage();
			assertTrue("Parsing Failed", r2 != null);
	}

	public void testToStringStringString() {
		assertEquals(s1.toLowerCase(),r1.toString(" \r\n", "\r\n\r\n\r\n").toLowerCase());
		assertEquals(s2.toLowerCase(),r2.toString(" \r\n", "\r\n\r\n\r\n").toLowerCase());
	}

}
